interface Props {
  id: string;
  children: number[];
}

// 将属性和方法变为可选项
type PartialProps = Partial<Props>;
let p1: Props = {
  id: "1001",
  children: [1, 2],
};
let p2: PartialProps = {
  children: [1, 2],
};
p2.children = [3, 4];
console.log(p1);
console.log(p2);

// 所有的属性和方法都为只读
type ReadonlyProps = Readonly<Props>;
let p3: ReadonlyProps = {
  id: "1001",
  children: [1, 2],
};
console.log(p3);

interface Props2 {
  id: string;
  tiltle: string;
  children: number[];
}
// 选择属性
type PickProps2 = Pick<Props2, "id" | "children">;
let p4: PickProps2 = {
  id: "1001",
  children: [1, 2],
};
console.log(p4);

// 记录属性, 简化类的创建(属性类型一致)
type RecordProps = Record<"a" | "b" | "c" | "d", string[]>;
let p5: RecordProps = {
  a: ["1", "2"],
  b: ["3", "4"],
  c: ["5", "6"],
  d: ["7", "8"],
};
console.log(p5);
